package com.ruoyi.yz.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.utils.file.ImageUtils;
import com.ruoyi.face.domain.ImageType;
import com.ruoyi.face.domain.Member;
import com.ruoyi.yz.util.valid.Phone;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;

import javax.validation.constraints.NotBlank;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Date;

/**
 * 参会人员对象 yz_member
 *
 * @author yz
 * @date 2024-06-14
 */
public class YzMember extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /**  */
    private Long id;

    /** 会议ID */
    private Long conferenceId;

    /** 会议名称 */
    @Excel(name = "会议名称")
    private String conferenceName;

    /** 姓名 */
    @NotBlank(message = "姓名不能为空")
    @Excel(name = "姓名")
    private String name;

    /** 手机 */
    @Phone(message = "手机号码不正确")
    @Excel(name = "手机")
    private String phone;

    /** 性别 */
    @NotBlank(message = "请选择性别")
    @Excel(name = "性别", readConverterExp="0=男,1=女")
    private String sex;

    /** 所属院校 */
    @NotBlank(message = "所属院校不能为空")
    @Excel(name = "所属院校")
    private String schoolName;

    /** 所属部门 */
    @NotBlank(message = "所属部门不能为空")
    @Excel(name = "所属部门")
    private String deptName;

    /** 职务 */
    @NotBlank(message = "职务不能为空")
    @Excel(name = "职务")
    private String job;

    /** 状态 */
    @Excel(name = "状态", readConverterExp="0=未签到,1=已签到")
    private String status;

    /** 个人照片 */
    @NotBlank(message = "请上传本人照片")
    @Excel(name = "个人照片")
    private String photo;

    @Excel(name = "签到时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date signinTime;

    @Excel(name = "备注")
    private String remark;

    @Override
    public String getRemark() {
        return remark;
    }

    @Override
    public void setRemark(String remark) {
        this.remark = remark;
    }

    public void setId(Long id)
    {
        this.id = id;
    }

    public Long getId()
    {
        return id;
    }

    public void setConferenceId(Long conferenceId)
    {
        this.conferenceId = conferenceId;
    }

    public Long getConferenceId()
    {
        return conferenceId;
    }

    public String getConferenceName() {
        return conferenceName;
    }

    public void setConferenceName(String conferenceName) {
        this.conferenceName = conferenceName;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public String getName()
    {
        return name;
    }

    public void setPhone(String phone)
    {
        this.phone = phone;
    }

    public String getPhone()
    {
        return phone;
    }

    public void setSex(String sex)
    {
        this.sex = sex;
    }

    public String getSex()
    {
        return sex;
    }

    public void setSchoolName(String schoolName)
    {
        this.schoolName = schoolName;
    }

    public String getSchoolName()
    {
        return schoolName;
    }

    public void setDeptName(String deptName)
    {
        this.deptName = deptName;
    }

    public String getDeptName()
    {
        return deptName;
    }

    public void setJob(String job)
    {
        this.job = job;
    }

    public String getJob()
    {
        return job;
    }

    public void setStatus(String status)
    {
        this.status = status;
    }

    public String getStatus()
    {
        return status;
    }

    public void setPhoto(String photo)
    {
        this.photo = photo;
    }

    public String getPhoto()
    {
        return photo;
    }

    public Date getSigninTime() {
        return signinTime;
    }

    public void setSigninTime(Date signinTime) {
        this.signinTime = signinTime;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("conferenceId", getConferenceId())
            .append("name", getName())
            .append("phone", getPhone())
            .append("sex", getSex())
            .append("schoolName", getSchoolName())
            .append("deptName", getDeptName())
            .append("job", getJob())
            .append("status", getStatus())
            .append("photo", getPhoto())
            .append("createBy", getCreateBy())
            .append("createTime", getCreateTime())
            .append("updateBy", getUpdateBy())
            .append("updateTime", getUpdateTime())
            .append("remark", getRemark())
            .toString();
    }

    public Member createDeviceMember() {
        Member member = new Member();
        member.setId(getId());
        member.setIsAdmin(false);
        member.setPersonName(getName());
        member.setRecognitionType("staff");
        member.setGroupList(Arrays.asList("1"));
        member.addImage(ImageType.FACE, ImageUtils.getImage(getPhoto()));

        return member;
    }
}
